#ifndef THREAD_POOL_H
#define THREAD_POOL_H

#include <vector>
#include <thread>
#include <functional>
#include <mutex>
#include "thread_safe_queue.h"

class ThreadPool
{
public:
    ThreadPool(size_t num_threads);
    ~ThreadPool();

    void enqueue(std::function<void()> task);

private:
    std::vector<std::thread> workers;
    ThreadSafeQueue<std::function<void()>> tasks;
    bool stop;
    std::mutex queue_mutex; // 添加互斥锁成员变量
};

#endif // THREAD_POOL_H